package com.lemon.smartsafety.app;


import com.google.gson.Gson;
import com.lemon.smartsafety.utils.GsonUtil;
import com.lemon.smartsafety.utils.app.SharedPreferencesHelper;
import com.lemon.safecloud.greendao.DBHelper;

import org.greenrobot.eventbus.EventBus;

/**
 * Created by Cooliean on 16/1/18.
 */
public class AppService {
    private static final AppService APP_SERVICE = new AppService();
    private static Gson                    mGson;
    private static EventBus                mBus;
    private static DBHelper                sDBHelper;
    private        SharedPreferencesHelper mSharedPreferencesHelper;


    private AppService() {
    }

    /**
     * 在Application 里面初始化了
     */
    public void initService() {
        mBus = EventBus.getDefault();
        mGson = GsonUtil.getCommonGson();
        sDBHelper = DBHelper.getInstance(IApplication.context());
        mSharedPreferencesHelper = new SharedPreferencesHelper(IApplication.context());

        try {
            //SDKInitializer.initialize(IApplication.context());
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    public static AppService getInstance() {
        return APP_SERVICE;
    }

    public static Gson getGson() {
        return mGson;
    }

    public static EventBus getBus() {
        return mBus;
    }

    public static DBHelper getDBHelper() {
        return sDBHelper;
    }


    public boolean isLogin() {
        return mSharedPreferencesHelper.isLogin();
    }

}
